﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using DAL;
/// <summary>
///User 的摘要说明
/// </summary>
namespace BLL
{
    public class User
    {
        public User()
        {


        }
        /// <summary>
        /// 查找库中是否有这个士兵 
        /// </summary>
        /// <param name="CardID"></param>
        /// <returns></returns>
        public static Soldier GetSodierByCardid(string CardID)
        {
            SoldierDataContext udc = new SoldierDataContext();
            var pp = from aa in udc.Soldier where aa.CardID == CardID select aa;
            if (pp.Count() > 0)
            {
                return pp.First();
            }
            else
            {
                return null;
            }
        }
        /// <summary>
        /// 查找用户表中有没有这个士兵
        /// </summary>
        /// <param name="UserName"></param>
        /// <returns></returns>
        public static DAL.User GetUserByUserName(string UserName)
        {
            UserDataContext udc = new UserDataContext();
            var pp = from aa in udc.User where aa.UserID == UserName select aa;
            if (pp.Count() > 0)
            {
                return pp.First();
            }
            else
            {
                return null;
            }
        }

        public static DAL.Soldier GetSoldierByID(Guid id)
        {
            SoldierDataContext db = new SoldierDataContext();
            var pp = from aa in db.Soldier where aa.SoldierID == id select aa;
            if (pp.Count() > 0)
            {
                return pp.First();
            }
            else
            {
                return null;
            }
        }
    }
}
